﻿@model Blog.Models.PostModel


<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
    <h2>Redigera Inlägg</h2>

@using (Html.BeginForm("EditPost", "Admin", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
        @Html.AntiForgeryToken()

        <div class="form-horizontal">
            <hr />
            @Html.ValidationSummary(true)

            <div class="form-group">
                @Html.LabelFor(model => model.Title, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.TextBoxFor(model => model.Title, new { @class = "form-control"})
                    @Html.ValidationMessageFor(model => model.Title)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.Content, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.TextAreaFor(model => model.Content, new { @class = "form-control", rows = 8 })
                    @Html.ValidationMessageFor(model => model.Content)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.CreationDate, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.CreationDate)
                    @Html.ValidationMessageFor(model => model.CreationDate)
                </div>
            </div>

            <div class="form-group">
                @Html.LabelFor(model => model.FeaturedImage, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.TextBoxFor(model => model.ImageUpload, new {@class = "form-control", type = "file" })
                    @Html.ValidationMessageFor(model => model.ImageUpload)
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-offset-2 col-md-10">
                    <input type="submit" value="Uppdatera" class="btn btn-default" />
                    @if (ViewBag.Saved != null)
                    {
                        <p style="color: red;">@ViewBag.Saved</p>
                    }
                </div>
            </div>

        </div>
    }
    
    <div>
        <table class="table">
            <tr>
                <th>
                   
                </th>
                <th>
                   
                </th>
                <th></th>
            </tr>
                @if(Model.Comments !=null)
                { 
                    foreach (var comment in Model.Comments)
                    {
                        <tr>
                            <td>
                                @Html.DisplayFor(modelItem => comment.CommentText)
                            </td>
                            <td>
                                @Html.DisplayFor(modelItem => comment.CreationDate)
                            </td>
                            <td>
                                @Html.ActionLink("Radera", "DeleteComment", new { id = comment.CommentId })
                            </td>
                        </tr>
                    }
                }

        </table>
        

    </div>
    <div>
        @Html.ActionLink("Back to List", "Index")
    </div>
</div>

@section scripts
{
    @Scripts.Render("~/bundles/jqueryval")
}
